extends Control

onready var yuan1: CanvasLayer = $yuan1
onready var yuan2: CanvasLayer = $yuan2

var starting = false
var started = false
var velocity = 0

func _process(delta: float) -> void:
	if not starting:
		yuan2.offset.x = get_viewport().get_visible_rect().size.x
	elif not started:
		velocity = delta * (yuan2.offset.x - yuan1.offset.x) * 3.0
		yuan1.offset.x += velocity
		yuan2.offset.x -= velocity
		
		if yuan2.offset.x - yuan1.offset.x < 1:
			started = true
			Globals.load_scene(Globals.Drama, 0.5)
	pass


func _on_start_pressed() -> void:
	starting = true


func _on_leave_pressed() -> void:
	get_tree().quit()
